<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      function fun1() {
        var a = 100;
        return function fun2() {
          alert(a);
        };
      }

      let res = fun1();
      res();

      //函数嵌套函数，内层函数访问外层函数的变量，
      //这个变量在外层函数执行完后还不被销毁，因为它被别的函数使用了
    </script>
  </body>
</html>
